<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>菜鸟hh</title>
</head>

<body bgcolor="green">

<p id="p1">ffr</p>
<p id="p2">时间</p>
<p id="p3">N秒后</p>

<script>

x = window.innerWidth
y = window.innerHeight
document.write("窗口规格:" + x + ":" + y + "<br>")
document.write("窗口规格:" + screen.availWidth + ":" + screen.availHeight + "<br>")

var lc = location.hostname + "<br>" + 
        location.pathname + "<br>" + 
        location.port + "<br>" + 
        location.protocol + "<br>" + 
        location.href
document.write("win location:" + lc + "<br>")

function loadNewDoc() {
    window.location.assign("https://baidu.com")
}

//这与在浏览器中点击后退按钮是相同的：
function goBack() {
    window.history.back()
}

function onSure() {
    var r = confirm("确定吗")
    if (r == true) {
        document.getElementById("p1").innerHTML = "按下确定"
    } else {
        document.getElementById("p1").innerHTML = "按下取消"
    }
}
function onInput() {
    var r = prompt("请输入", "ssafd34")
    if (r != null && r != "") {
        document.getElementById("p1").innerHTML = r
    } else {
        document.getElementById("p1").innerHTML = "无效"
    }
}

document.getElementById("p1").innerHTML = navigator.appCodeName
tm = setInterval(function() {
    //var t = (new Date).toLocaleDateString()
    document.getElementById("p2").innerHTML = new Date()
}, 1000);

function stopTm() {
    clearInterval(tm)
}

var tmP3
function startP3() {
    tmP3 = setTimeout(function() {
        document.getElementById("p3").innerHTML = "55555555555555"
    }, 3000)

    tm = setInterval(function() {
        //var t = (new Date).toLocaleDateString()
        document.getElementById("p2").innerHTML = new Date()
    }, 1000);
}

function stopP3() {
    clearTimeout(tmP3)
}

document.write("域名："+document.domain+"<br>")
document.write("链接数:"+document.links.length+"<br>")
document.write("p3 top:"+document.getElementById("p3").clientTop+"<br>")


</script>

<button onclick="loadNewDoc()">加载新文档</button><br>
<input type="button" value="加载url" onclick="loadNewDoc()"><br>
<input type="button" value="退前一个url" onclick="goBack()"><br>
<input type="button" value="确认" onclick="onSure()"><br>
<input type="button" value="输入" onclick="onInput()"><br>
<input type="button" value="停止" onclick="stopTm()"><br>

<input type="button" value="开启p3" onclick="startP3()"><br>
<input type="button" value="停止p3" onclick="stopP3()"><br>


</body>
</html>

